@extends('Admin.layouts.common')

@section('content')
    <div class="container myContainer">

        <button class="btn btn-info searchBtn" onclick="$('.search_box').slideToggle();">搜索/筛选</button>
        <div class="search_box">
            <form id="search_form" method="GET">
            	<label>
                    Uid：<br>
                    <input type="text" name="uid" class="form-control search_form_control" value="{{$_search['uid']??''}}">
                </label>
                <label>
                    邀请码：<br>
                    <input type="text" name="invitation_code" class="form-control search_form_control" value="{{$_search['invitation_code']??''}}">
                </label>
                <label>
                    手机号<br>
                    <input type="text" name="phone" class="form-control search_form_control" value="{{$_search['phone']??''}}">
                </label>
                
                <button class="btn btn-primary" type="submit">&nbsp;&nbsp;确定&nbsp;&nbsp;</button>
            </form>
        </div>

        <div id="order_tag"></div>

        <div class="table-responsive">
            <table class="table">
                <caption>{{$title}}</caption>
                <thead>
                    <tr>
                        <th>Uid</th>
                        <th>手机号</th>
                        <th>总收益</th>
                        <th>可提现金额</th>
                        <th>师傅ID</th>
                        <th>微信openid</th>
                        <th>注册时间</th>
                        <th>封禁时间</th>
                        <th>封禁原因</th>
                        <th>用户状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse($list->items() as $item)
                        <tr id="tr_{{$item->id}}">
                            <td><a href="/money/user_moneylog?_search={{urlencode("uid=".$item->uid)}}"> {{ $item->uid }}</a></td>
                            <td> {{ urldecode($item->phone) }} </td>
                            <td>{{$item->profit}}</td>
                            <td>{{$item->money}}</td>
                            <td>{{$item->tj_id}}</td>
                            <td>{{$item->openid}}</td>
                            <td>{{date('Y/m/d H:i:s',$item->time)}}</td>
                            <td>{{date('Y/m/d H:i:s',$item->closure_time)}}</td>
                            <td>{{$item->closure_rreason}}</td>
                            <td>{{$status[$item->status]}}</td>
                            <td>
                                <a href="javascript:;" onclick="up_status({{$item->uid}},1)">取消封禁/限制</a><br/>
                                <a href="/cash/tx?_search={{urlencode('uid='.$item->uid)}}">提现记录</a>
                            </td>
                        </tr>
                    @empty
                        <tr><td class="text-center" colspan="20">没有数据</td></tr>
                    @endforelse
                </tbody>
            </table>
            <div class="text-center">
                {{ $list->links() }}
            </div>
        </div>

    </div>
    <link href="{{ asset('libs/select2/select2.min.css') }}" rel="stylesheet">
<script src="{{ asset('libs/select2/select2.min.js') }}"></script>
<script src="{{ asset('libs/select2/zh-CN.js') }}"></script>
<script type="text/javascript">
$("#uid").select2({
    language: "zh-CN",
    ajax:{
        url: "/Users/ajax_select2_user",
        dataType: 'json',
        delay: 600,
        method: 'POST',
        data: function (params) {
            return {
                name: params.term,
            };
        },
        processResults: function (data, params) {
            return {
                results: data.data,
            };
        },
        cache: true
    },
    placeholder:'请输入手机号码',
    allowClear: true,
    escapeMarkup: function (markup) { return markup; },
    minimumInputLength: 11,
    templateResult: function(repo){ return repo.name; },
    templateSelection: function(repo){ 
        if(repo.id === ""){
            return repo.text
        }else{
            if(repo.selected == true){
                return repo.text
            }
            return repo.name
        }
         
    } 
});
</script>

<script type="text/javascript">
$.ajaxSetup({
    headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
})

function ajax_delete_theme(id){
    if(confirm('确认删除吗?')){
        $.post("/admins/ajax_delete_admin/"+id,{},function(json){
            if(json.status==1){
                $("#tr_"+json.data).fadeOut();
            }else{
                alert(json.info);
            }
        },"json");
    } 
}

function up_status(id,status){
    if(confirm("确认执行操作吗?")){
        $.post("/user/ajax_up_status/"+id,{status:status},function(json){
            if(json.status==1){
                window.location.reload();
            }else{
                alert(json.info);
            }
        },"json");
    }
}
function ajax_up_level(id,level){
    if(confirm("确认执行操作吗?")){
        $.post("/user/ajax_up_level/"+id,{level:level},function(json){
            if(json.status==1){
                window.location.reload();
            }else{
                alert(json.info);
            }
        },"json");
    }
}
function fengjing(uid,status){
    var title = status==1?'封禁':'限制';
    layx.iframe('localsite',title,'/user/ajax_update_status/'+uid+'?status='+status);
}

function prohibit(uid){
    layx.iframe('localsite','封禁/解封日志','/user/prohibit/'+uid);
}
</script>
@endsection